// Query.cpp : Implementation of CQuery

#include "stdafx.h"
#include "Query.h"
#include "SqlQueryBuilder.h"

// CQuery


STDMETHODIMP CQuery::get_SelectionCriteria(BSTR* pVal)
{
    *pVal = m_SelectionCriteria;
    return S_OK;
}

STDMETHODIMP CQuery::put_SelectionCriteria(BSTR newVal)
{
    m_SelectionCriteria = newVal;
    return S_OK;
}

STDMETHODIMP CQuery::get_CountOnly(VARIANT_BOOL* pVal)
{
    *pVal = m_CountOnly;
    return S_OK;
}

STDMETHODIMP CQuery::put_CountOnly(VARIANT_BOOL newVal)
{
    m_CountOnly = newVal;
    return S_OK;
}

STDMETHODIMP CQuery::get_DatastoreItemType(TsDatastoreItemTypeEnum* pVal)
{
    *pVal = m_DatastoreItemType;
    return S_OK;
}

STDMETHODIMP CQuery::put_DatastoreItemType(TsDatastoreItemTypeEnum newVal)
{
   m_DatastoreItemType = newVal;
    return S_OK;
}

HRESULT CQuery::GetSql(_bstr_t pSql)
{
    _bstr_t sqlText;
    if(CSqlQueryBuilder::GetInstance().GetSqlString(m_DatastoreItemType, m_SelectionCriteria, sqlText))
    {
        return S_OK;
    }
    return E_FAIL;
}
